<template>
    <div>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>权益名称</td>
                    <td><input type="text" v-model="add.qname"></td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        <input type="radio" v-model="add.tyle" name="tyle" :value=true>启用
                        <input type="radio" v-model="add.tyle" name="tyle" :value=false>未启用
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="修改权益" @click="ok"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref, reactive, onMounted } from "vue";
import moment from 'moment';
import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const route = useRoute();

let add: any = reactive(
    {
        id: route.query.id,
        "qname": "",
        "tyle": true,
        "isdel": true
    }
)
onMounted(() => {
    ft();
})
const ft = () => {
    axios({
        url: 'https://localhost:7104/api/Emp/ftq',
        method: 'get',
        params: {
            id: route.query.id
        }
    })
        .then(res => {
            console.log(res);
            Object.assign(add, res.data)
        })
        .catch(err => {
            console.log(err);

        })
}
const ok = () => {
    axios(
        {
            url: 'https://localhost:7104/api/Emp/updateq',
            method: 'post',
            data: add
        }
    )
        .then(res => {
            console.log(res);
            if (res.data > 0) {
                alert("修改成功");
                router.push("/Qshow")
            }
        })
        .catch(err => {
            console.log(err);

        })
}
</script>

<style scoped></style>